import numpy as np

def T_mix(T):
    TM = np.sqrt( np.outer(T, T) )
    return TM

def P_mix(P):
    PM = ( P + P.T ) / np.size(P)
    return PM

def w_mix(w):
    wM = ( w + w.T ) / np.size(w)
    return wM

def Z_mix(Z):
    ZM = ( Z + Z.T ) / np.size(Z)
    return ZM

def M_mix(M):
    MM = ( M + M.T ) / np.size(M)
    return MM

def b_mix(b, x):
    bM = np.dot(b.flatten(), x.flatten())
    return bM

def a_mix(a, x):
    x = x * x.T
    a = np.sqrt( (a * a.T) )
    aM = np.dot(a.flatten(), x.flatten())
    return aM

def xya_mix(a, x):
    a = np.sqrt( (a * a.T) )
    xya = np.dot(a, x).flatten()
    return xya